package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.pb.OreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_CROSS_ORE_WAR_TOP_BUILDING, desc = "跨服返回第一坑位信息")
public class CrossOreTopBuildMsgCmd extends AbstractCommand {

	private int activityId;

	List<CrossUserOrePit> crossUserOrePitList = new ArrayList<>();

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossOreTopBuildingDetailRespMsg crossSyncMsg = OreWarProto.CrossOreTopBuildingDetailRespMsg.parseFrom(packet.getBytes());
		ret = crossSyncMsg.getRet();
		if(ret == 0){
			crossUserOrePitList = OreWarPb.parseCrossOrePitList(crossSyncMsg.getOrePitListList());
			OreWarProto.OreTopBuildingDetailRespMsg.Builder respMsg = OreWarPb.parseCrossOreTopBuildingDetailRespMsg(crossUserOrePitList);
			player.sendPacket(Protocol.U_ORE_WAR_TOP_BUILDING_DETAIL, respMsg);
		}else{
			OreWarProto.OreTopBuildingDetailRespMsg.Builder respMsg = OreWarProto.OreTopBuildingDetailRespMsg.newBuilder();
			respMsg.setRet(ret);
			player.sendPacket(Protocol.U_ORE_WAR_TOP_BUILDING_DETAIL, respMsg);
		}
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
